﻿//-----------------------------------------------------------------------
// <copyright>
// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
// </copyright>
//----------------------------------------------------------------------- 
using System.Reflection;
using Fulcrum.DispatcherProxies;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Fulcrum.UnitTests.DispatcherProxies
{
    [TestClass]
    public class DispatcherProxyPropertyInfoTests
    {
        public DispatcherProxyPropertyInfoTests()
        {
            // nothign
        }

        PropertyInfo propertyInfo;
        DispatcherProxyPropertyInfo proxyPropertyInfo;

        [TestInitialize]
        public void TestInitalize()
        {
            this.propertyInfo = GetPropertyInfo();
            this.proxyPropertyInfo = new DispatcherProxyPropertyInfo(this.propertyInfo, true, true, true);
        }

        PropertyInfo GetPropertyInfo()
        {
            var type = this.GetType();
            var property = type.GetProperty("MyProperty");
            return property;
        }

        public int MyProperty
        {
            get;
            private set;
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoName()
        {
            Assert.AreEqual("MyProperty", this.proxyPropertyInfo.Name);
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoCanRead()
        {
            Assert.AreEqual(true, this.proxyPropertyInfo.CanRead);
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoCanWrite()
        {
            Assert.AreEqual(true, this.proxyPropertyInfo.CanWrite);
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoIsNew()
        {
            Assert.AreEqual(true, this.proxyPropertyInfo.IsNew);
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoObsoleteAttribute()
        {
            Assert.IsNull(this.proxyPropertyInfo.ObsoleteAttribute);
        }

        [TestMethod]
        public void TestDispatcherProxyPropertyInfoPropertyType()
        {
            Assert.AreEqual(typeof(int), this.proxyPropertyInfo.PropertyType);
        }
    }
}
